<?php

require_once dirname(__FILE__) . '/../lib/modulo_cohorteGeneratorConfiguration.class.php';
require_once dirname(__FILE__) . '/../lib/modulo_cohorteGeneratorHelper.class.php';

/**
 * modulo_cohorte actions.
 *
 * @package    sistema_itec_new
 * @subpackage modulo_cohorte
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class modulo_cohorteActions extends autoModulo_cohorteActions {

    protected function processForm(\sfWebRequest $request, \sfForm $form) {
        $modulo_cohorte = $request->getParameter('modulo_cohorte');
        $modulo_cohorte['fecha_desde'] = date('Y-m-d', strtotime(str_replace('/', '-', $modulo_cohorte['fecha_desde'])));
        $modulo_cohorte['fecha_hasta'] = date('Y-m-d', strtotime(str_replace('/', '-', $modulo_cohorte['fecha_hasta'])));
        $request->setParameter('modulo_cohorte', $modulo_cohorte);

        parent::processForm($request, $form);
    }

    public function executePrintList(sfWebRequest $request) {
        $this->modulo = Doctrine::getTable('ModuloCohorte')->findOneById($request->getParameter('id'));
        $this->alumnos_inscriptos = Doctrine::getTable('ModuloCohorte')->getAlumnosInscriptos($this->modulo->getId());
        $this->setLayout(false);
        sfConfig::set('sf_web_debug', false);
        $filename = $this->modulo->getModulo().'_'.$this->modulo->getCohorteUnidadFormacion();
        header("Content-Type: application/vnd.ms-excel ; charset=UTF-8");
        header('Content-Disposition: attachment; filename="'.$filename.'.xls"');
        return $this->renderPartial('printList');
    }

}
